home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / cenvi2.arj / BUGHUNT.CMD < prev    next >
OS/2 REXX Batch file  |  1993-10-13  |  3KB  |  84 lines

  1. @echo off
  2. REM ******************************************************
  3. REM *** Install the rest of this code to stay resident ***
  4. REM ******************************************************
  5.  
  6. start "BugHunt" /N /B /WIN /MIN CEnvi "#include 'BugHunt.cmd,,,/*RESIDENT*/'"
  7. call WinSet BugHunt HIDE
  8. EXIT
  9.  
  10. /*RESIDENT*/
  11. /*************************************************************************
  12.  *** BugHunt.cmd - Example program for using the ClipBoard routines in ***
  13.  ***               ClipBrd.lib.  This is a very silly program that     ***
  14.  ***               searches every few seconds for the text of "bug"    ***
  15.  ***               anywhere in the clipboard text.                     ***
  16.  ***                                                                   ***
  17.  ***               This program also demonstrates the unusual          ***
  18.  ***               technique of calling CEnvi to execute code contain  ***
  19.  ***               within the source of another CEnvi program.         ***
  20.  *************************************************************************/
  21.  
  22. #define  BUGHUNT_FREQUENCY    5   // how many seconds to wait between hunts
  23.  
  24. #include <ClipBrd.lib>
  25. #include <MsgBox.lib>
  26.  
  27.  
  28. MessageBox("This program will search for\n"
  29.            "bugs in your clipboard. That\n"
  30.            "is, it will search for the\n"
  31.            "word \"bug\" (case-insensitive)\n"
  32.            "and ask you if you want to\n"
  33.            "delete the clipboard if a\n"
  34.            "\"bug\" is found.",
  35.            "EXTERMINATOR!");
  36.  
  37.  
  38. for(;;) {   // FOREVER
  39.    ClipText = GetClipboardData(CF_TEXT);
  40.    if ( ClipText != NULL ) {
  41.       // check clipboard, case-insensitive, for the "bug" string
  42.       while ( NULL != (ClipText = strpbrk(ClipText,"Bb")) ) {
  43.          // check if the rest of this is "ug"
  44.          if ( !memicmp(++ClipText,"ug",2) ) {
  45.             if ( ExterminationWanted() )
  46.                ExterminateTheClipboard();
  47.             break;
  48.          }
  49.       }
  50.    }
  51.    suspend(BUGHUNT_FREQUENCY * 1000);
  52. }
  53.  
  54. ExterminationWanted() // Return TRUE if user wants to delete the clipboard
  55. {
  56.    return ( MBID_YES == MessageBox("A bug has been found in\n"
  57.                                    "the clipboard. Should the\n"
  58.                                    "clipboard be exterminated?",
  59.                                    "EXTERMINATOR!",
  60.                                    MB_WARNING|MB_MOVEABLE|MB_YESNO) );
  61. }
  62.  
  63. ExterminateTheClipboard() // spawn message program to run while this program
  64. {                         // deletes the text in the clipboard.
  65.    // Run another CEnvi process to tell that extermination is happening.
  66.    // That other program will read the code from this program; weird, huh!
  67.    system("start /N /WIN /MAX CEnvi \"#include <BugHunt.cmd,,//Exterminator!>\" ");ugh
  68.    // while that's going on, we'll simultaneously delete the clipboard
  69.    PutClipboardData(NULL);
  70. }
  71.  
  72.  
  73. // The text below, which is a comment in this program, is the CODE for another
  74. // instance of CEnvi which was spawned above in the ExterminateTheClipboard()
  75. // routine.  Since Windows is multitasking (sort of) this code will be running
  76. // while the original instance of CEnvi is deleting the clipboard.
  77.  
  78. //Exterminator!   for ( i = 0; i < 100; i++ ) {
  79. //Exterminator!      printf("Bug!\tEEEK!\t");
  80. //Exterminator!   }
  81. //Exterminator!   suspend(500);
  82. //Exterminator!   printf("\nCLIPBOARD EXTERMINATED!");
  83. //Exterminator!   suspend(500);
  84.